﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ComTools.Attributes
{

    /// <summary>
    /// 数据特性验证的基类
    /// </summary>
    public abstract class AbstractValidateAttribute : Attribute
    {
        public abstract bool Validate(object value);
    }

    /// <summary>
    /// 实现NullEmpty特性
    /// </summary>
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
    public sealed class NullEmptyAttribute : AbstractValidateAttribute
    {
        public override bool Validate(object value)
        {
            if (null == value) return true;
            return string.IsNullOrEmpty(value.ToString());
        }
    }


}
